<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_funcionario.xhtml">
	<ui:define name="corpo">

		<div id="conteudo">

			<h:form id="form">

				<h2>
					<h:outputText value="Alterar Perfil do Funcionário"/>
				</h2>

				<p:messages id="msg" />
					
				<p:fieldset legend="Pesquisar" style="background-image: url(resources/imagens/72.jpg);">
				
				<h:outputLink value="javascript:void(0)" onclick="dlgFunc.show();" >
					<h:outputLabel value="Pesquisar Funcionário: " style="text-decoration: none" />
				</h:outputLink>
				<h:outputLink value="javascript:void(0)" onclick="dlgFunc.show();" style="text-decoration: none;">
				<h:graphicImage value="resources/imagens/pesquisa_func.png"  onclick="dlgFunc.show();"
					style="width: 40px;" />&nbsp;&nbsp;&nbsp;
				<h:outputText id="func" value="#{funcionarioBean.funcionario.nome}" style="color: #1E90FF; font-weight:bold; text-decoration: none" />
				</h:outputLink>

				</p:fieldset>
				
				<h:panelGrid columns="3">
				<p:fieldset style="background-image: url(resources/imagens/72.jpg);" >
				
				
				<h:outputLabel value="Matrícula: " for="matricula" style="color: #1E90FF; font-weight:bold;" />
				<h:outputText id="matricula" value="#{funcionarioBean.funcionario.matricula}" /><br /><br />
				
				<h:outputLabel value="Nome: " for="nome" style="color: #1E90FF; font-weight:bold;" />
				<h:outputText id="nome" value="#{funcionarioBean.funcionario.nome}" style="width: 300px;" /><br /><br />
					
				<h:outputLabel value="Setor: " for="setor" style="color: #1E90FF; font-weight:bold;" />
				<h:outputText id="setor" value="#{funcionarioBean.funcionario.setor.nome}"  /><br /><br />
					
<!-- 					Aparece somente quando o id for vazio -->									
				<h:outputLabel value="Perfil: " for="perfil" style="color: #1E90FF; font-weight:bold;" />
				<h:outputText id="perfil2" value="#{funcionarioBean.funcionario.perfil}" rendered="#{empty funcionarioBean.funcionario.id}" />
				
<!-- 					Aparece somente quando o id não for vazio, é o mesmo campo acima -->
				<h:selectOneMenu id="perfil"  value="#{funcionarioBean.funcionario.perfil}" rendered="#{not empty funcionarioBean.funcionario.id}"  >
					<f:selectItem itemLabel="Usuário" itemValue="Usuário" />
					<f:selectItem itemLabel="Administrador" itemValue="Administrador" />
				</h:selectOneMenu>
				<br /><br />
				
				<p:commandButton id="grava" value="ALTERAR" action="#{funcionarioBean.edita}" ajax="false" image="ui-icon-pencil" update="msg"
					rendered="#{not empty funcionarioBean.funcionario.id}" style="margin-left: 100px">
					<f:ajax render="@all" />
				</p:commandButton>
					
				<br />
				
				</p:fieldset>
				</h:panelGrid>

			</h:form>	
			
			<p:dialog header="Setores Cadastrados" widgetVar="dlgSetor" model="true" width="600" showEffect="hide">
					<h:form id="form1">

						<p:outputPanel id="setores">
							<p:dataTable value="#{setorBean.setores}" var="setor" paginator="true"
								rows="10" emptyMessage="Não Encontrado">

								<p:column filterBy="#{setor.nome}" filterMatchMode="contains"
									headerText="Nome do Setor">
									<h:commandLink value="#{setor.nome}" onclick="dlgSetor.hide()"
										id="setor">
										<f:setPropertyActionListener
											target="#{funcionarioBean.funcionario.setor}" value="#{setor}" />
									</h:commandLink>
								</p:column>
								
								<p:column headerText="Orgão">
									<h:outputText value="#{setor.orgao.nome}" />
								</p:column>
									
							</p:dataTable>
						</p:outputPanel>

					</h:form>
				</p:dialog>
				
				<p:dialog header="Funcionários Cadastrados" widgetVar="dlgFunc" modal="true"
				width="500" showEffect="clip" resizable="false">
				<h:form id="form2">

					<p:outputPanel id="funcs">
					<p:growl id="grow" showDetail="true" sticky="true">
					
						<p:dataTable value="#{funcionarioBean.funcionarios}" var="funcionario"
							paginator="true" rows="10" dynamic="true" emptyMessage="Não Encontrado">	
								

							<p:column filterBy="#{funcionario.matricula}" filterMatchMode="contains"
								headerText="Matrícula" sortBy="#{funcionario.matricula}">								
								<h:commandLink value="#{funcionario.matricula}" onclick="dlgFunc.hide()">
									<f:setPropertyActionListener target="#{funcionarioBean.funcionario}" value="#{funcionario}" />
								</h:commandLink>
							</p:column>
							
							<p:column filterBy="#{funcionario.nome}"  filterMatchMode="contains"	
								headerText="Nome" > 
									<h:outputText value="#{funcionario.nome}" />
							</p:column>
							
						</p:dataTable>
					</p:growl>	
					</p:outputPanel>

				</h:form>
			</p:dialog>
							
		</div>


	</ui:define>
</ui:composition>
</html>